﻿@model SisGAC.Models.Pessoa

@{
    ViewBag.Title = "Cadastro";
}
@Styles.Render("~/Content/themes/base/css")
<h2>Cadastro</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Pessoa</legend>
        
        @Html.HiddenFor(model => model.PessoaId)
        @Html.HiddenFor(model => model.Account.UserId)
        @Html.HiddenFor(model => model.Account.UserName)
        <input type="hidden" name="CPFAtual" value="@Model.CPF" />
        
        <div class="editor-label">
            @Html.LabelFor(model => model.CPF)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CPF)
            @Html.ValidationMessageFor(model => model.CPF)
        </div>
        
        @if (!Model.Autor) 
        {
            <div class="editor-label">
                @Html.LabelFor(model => model.RG)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.RG)
                @Html.ValidationMessageFor(model => model.RG)
            </div>
        }

        <div class="editor-label">
            @Html.LabelFor(model => model.Nome)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Nome)
            @Html.ValidationMessageFor(model => model.Nome)
        </div>

        @if (!Model.Autor)
        {
        <div class="editor-label">
            @Html.LabelFor(model => model.Endereco)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Endereco)
            @Html.ValidationMessageFor(model => model.Endereco)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Profissao)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Profissao)
            @Html.ValidationMessageFor(model => model.Profissao)
        </div>
        }
        
        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>
        
        @if (!Model.Autor)
        {
        <div class="editor-label">
            @Html.LabelFor(model => model.Telefone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Telefone)
            @Html.ValidationMessageFor(model => model.Telefone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DataNascimento)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DataNascimento)
            @Html.ValidationMessageFor(model => model.DataNascimento)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Formacao)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Formacao)
            @Html.ValidationMessageFor(model => model.Formacao)
        </div>
        }
        <div class="editor-label">
            @Html.LabelFor(model => model.Instituicao)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Instituicao)
            @Html.ValidationMessageFor(model => model.Instituicao)
        </div>

        @Html.HiddenFor(model => model.Usuario)

        @if (ViewBag.TipoAcesso == 1)
        {
            <div class="editor-field">@Html.CheckBoxFor(model => model.Autor) @Html.LabelFor(model => model.Autor, new { @style = "font-weight:100;display: inline-block;" })</div>
            <div class="editor-field">@Html.CheckBoxFor(model => model.Coordenador) @Html.LabelFor(model => model.Coordenador, new { @style = "font-weight:100;display: inline-block;" })</div>
            <div class="editor-field">@Html.CheckBoxFor(model => model.Avaliador) @Html.LabelFor(model => model.Avaliador, new { @style = "font-weight:100;display: inline-block;" })</div>
        }
        else
        {
            @Html.HiddenFor(model => model.Autor)
        }

        <p>
            <input type="submit" value="Salvar" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Voltar para Lista", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
<script type="text/javascript">
    $(function () {
        $("#Telefone").val('');
        //$("#DataNascimento").val('');
        $("#DataNascimento").datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'dd-mm-yy'
        });
        $("#DataNascimento").datepicker("option",
                $.datepicker.regional["pt-BR"]);
    });
    
</script>
}
